服务器_ASP.net 自定义服务器控件之 GridViewControl,根据项目需要,提供自定义服
use the template this.EmptyDataTemplate.InstantiateIn(cellBody); else //the second row, use the EmptyDataText cellBody.Text = this.EmptyDataText; cellBody.HorizontalAlign = HorizontalAlign.Left; cellBody.ColumnSpan = this.Columns.Count; rowBody.Cells.Add(cellBody); tblHeader.RenderControl(writer); } protected override void Render(HtmlTextWriter writer) { if (_enableEmptyContentRender (this.Rows.Count == 0 || this.Rows[0].RowType == DataControlRowType.EmptyDataRow)) RenderEmptyContent(writer); else base.Render(writer); } } , 根据项目需要,提供自定义服务器控件之 GridViewControl,提供数据为空时的自定义显示。
[DefaultProperty("EnableEmptyContentRender")] [ToolboxData("{0}:GridViewControl runat=server/{0}:GridViewControl")] public class GridViewControl : System.Web.UI.WebControls.GridView { /// summary /// 是否数据为空时显示标题行 /// /summary private bool _enableEmptyContentRender = true; /// summary /// 是否数据为空时显示标题行 /// /summary [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public bool EnableEmptyContentRender { set { _enableEmptyContentRender = value; } get { return _enableEmptyContentRender; } } /// summary /// 是否数据为空时显示标题行 /// /summary private string _EmptyDataCellCssClass; /// summary /// 为空时信息单元格样式类 /// /summary [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public string EmptyDataCellCssClass { set { _EmptyDataCellCssClass = value; } get { return _EmptyDataCellCssClass; } } /// summary /// 为空时输出内容 /// /summary /// param name="writer"/param protected virtual void RenderEmptyContent(HtmlTextWriter writer) { //Create Header Table Table tblHeader = new Table(); //Copy All Property tblHeader.CssClass = this.CssClass; tblHeader.GridLines = this.GridLines; tblHeader.BorderStyle = this.BorderStyle; tblHeader.BorderWidth = this.BorderWidth; tblHeader.CellPadding = this.CellPadding; tblHeader.CellSpacing = this.CellSpacing; tblHeader.HorizontalAlign = this.HorizontalAlign; tblHeader.Width = this.Width; tblHeader.CopyBaseAttributes(this); TableRow rowHeader = new TableRow(); tblHeader.Rows.Add(rowHeader); rowHeader.CssClass = "TableHeader"; //Generate Table Header foreach (DataControlField f in this.Columns) { TableCell cell = new TableCell(); cell.Text = f.HeaderText; rowHeader.Cells.Add(cell); } TableRow rowBody = new TableRow(); tblHeader.Rows.Add(rowBody); TableCell cellBody = new TableCell(); cellBody.CssClass = this._EmptyDataCellCssClass; if (this.EmptyDataTemplate != null) //the second row,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/server/yun/11714.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
租用云服务器后的备案问
时间:2021-01-05
-
百度云服务器bcc有什么优
时间:2021-01-05
-
什么是云服务器cvm?怎么
时间:2021-01-05
-
云服务器怎么保证信息安
时间:2021-01-05
-
云服务器怎么预防被攻击
时间:2021-01-05
-
阿里云ECS实例设置用户r
时间:2020-12-29
-
阿里云ECS服务器入门使用
时间:2020-12-29
-
怎么配置云服务器
时间:2020-12-28
热门文章
-
租用云服务器后的备案问题你真的了解吗
时间:2021-01-05
-
选择美国云服务器需要关注什么?
时间:2020-12-27
-
阿里云服务器怎么买?阿里云服务器购买
时间:2020-12-25
-
运维必须知道的关于云服务器的十个问题
时间:2020-12-24
-
如何快速搭建一个阿里云服务器
时间:2020-12-24
-
什么是云?什么是云服务?什么是云主机
时间:2020-12-25
-
云服务器网站承载量一般有多大?一个云
时间:2020-12-28
-
浅谈云服务器和独立服务器的八大差异
时间:2020-12-24
-
SugarHosts云服务器如何开启访问端口和使用
时间:2020-12-24
-
云服务器是什么,云主机干什么用的?
时间:2020-12-28
